addModule({
	name: "Photo",
	init: function(){
		addSceneFunc("photo", this.func_scene, this.name, null);
		
		this.scanConfig();
	},
	
	temp: null,
	
	config: {
		imgSrcs: [
			"abc.jpg"
		],
		// 每个图片展示的时长, 支持 number 和 array(number)
		interval: 5000
	},
	
	require : function() {
		var array = [];
		
		for (var index = 0; index < this.config.imgSrcs.length; index++) {
			array.push({
				"name" : this.config.imgSrcs[index],
			    "type" : "image"
			});
		}
		
		return array;
	},
	
	scanConfig : function () {
		this.temp = {
			count : 0,
			imgPtr : {}
		};
		
		var length = this.config.imgSrcs.length;
		if (typeof (this.config.interval) == 'number') {
			var array = [];
			for (var i = 0; i < length; i++) {
				array.push(this.config.interval);
			}
			this.config.interval = array;
		} else if (this.config.interval.length < length) { // array
			var array = this.config.interval;
			while (array.length < length) {
				array.push(array[array.length - 1]);
			}
		}
	},
	
	func_scene: function(){
		this.temp.length = this.config.imgSrcs.length;
		
		var thiz = this;
		addRenderFunc(this.name, function () {
			var times = thiz.temp.count;
			
			// 上一张图片消失
			if (times > 0) {
				var image = thiz.temp.imgPtr[times - 1];
				m_data.i.remove(image);
			}
			
			if (times == this.temp.length) {
				endScene();
				return;
			}
			
			// 图片出现
			var image = m_data.i.createImage({
				position : [_width * 0.5, _height * 0.45],
				anchor : [0.5, 0.5],
				image: {
					src: this.config.imgSrcs[0],
					width: _width,
					height: _height * 0.9
				}
			});
			m_data.i.elementShow(image);
			thiz.temp.imgPtr[times] = image;
			
			// 计数
			thiz.temp.count++;
        },{
		   once : false,
		   interval : this.config.interval
		});
	}
});
